package de.baumann.browser.fragments


import android.support.v7.widget.LinearLayoutManager
import android.view.View
import de.baumann.browser.R
import de.baumann.browser.adapter.TransferAdapter
import de.baumann.browser.api.net.vo.Transfer
import de.baumann.browser.base.BaseOdinFragment
import de.baumann.browser.iview.ITransferRecordView
import de.baumann.browser.present.TransferRecordPresenter
import de.baumann.browser.utils.ViewUtil.emptyView
import kotlinx.android.synthetic.main.fragment_transfer_record.*

/**
 *@author:
 *@date:2018/12/19 11:36
 *@discription: 转赠记录
 */
class TransferRecordFragment : BaseOdinFragment<ITransferRecordView, TransferRecordPresenter>(), ITransferRecordView {

    private lateinit var transferAdapter: TransferAdapter

    companion object {
        val instance: TransferRecordFragment by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            TransferRecordFragment()
        }
    }

    override fun getLayout(): Int {
        return R.layout.fragment_transfer_record
    }

    override fun initView(view: View) {
        rvTransfer.layoutManager = LinearLayoutManager(context)
        transferAdapter = TransferAdapter(R.layout.recycler_item_transfer_detail)
        transferAdapter.emptyView = emptyView(mContext)
        rvTransfer.adapter = transferAdapter
    }

    override fun createPresenter(): TransferRecordPresenter {
        return TransferRecordPresenter()
    }

    override fun createView(): ITransferRecordView {
        return this
    }

    override fun initData() {
        getPresenter().transList()
    }


    override fun setTransferRecordData(data: List<Transfer>?) {
        transferAdapter.setNewData(data)
    }

}
